﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using HA.Data;

namespace HA.ModFlow.Controls
{
   public class PCCoverageSetup
    {
       public PCCoverageSetup(Coverage coverage)
       {

           this._coverage = coverage;
           this._setup = (CoverageSetup)this._coverage.Setup.Clone();


           this._coverageName = this._coverage.Name;

           this._scTypes = new List<PCSCKVItem>();

           foreach (KeyValuePair<MAPSCType,bool> sc in this._setup.ScTypes)
           {

               PCSCKVItem item = new PCSCKVItem(sc.Key,sc.Value);

               this._scTypes.Add(item);
               
           }




           //需要更具不同的情况，来加入不同的值，否则值会过多


           this._arealTypes = new List<PCArealKVItem>();

           foreach (KeyValuePair<MAPArealType, bool> sc in this._setup.ArealTypes)
           {

               PCArealKVItem item = new PCArealKVItem(sc.Key, sc.Value);

               this._arealTypes.Add(item);

           }




           this._obsTypes = new List<PCOBSKVItem>();


           foreach (KeyValuePair<MAPObservationType, bool> sc in this._setup.ObservationTypes)
           {

               PCOBSKVItem item = new PCOBSKVItem(sc.Key, sc.Value);

               this._obsTypes.Add(item);

           }


 
       }



       Coverage _coverage;



       //内部属性副本
       CoverageSetup _setup;


       /// <summary>
       /// 图层属性设置
       /// </summary>
       public CoverageSetup Setup
       {
           get { return _setup; }
           set { _setup = value; }
       }


       List<PCSCKVItem> _scTypes;


       List<PCArealKVItem> _arealTypes;

       List<PCOBSKVItem> _obsTypes;


       string _coverageName;

       public string CoverageName
       {
           get { return _coverageName; }
           set { _coverageName = value; }
       }


        #region 公共属性


       public List<PCOBSKVItem> ObsTypes
       {
           get { return _obsTypes; }
           set { _obsTypes = value; }
       }
     


       public List<PCSCKVItem> ScTypes
       {
           get { return _scTypes; }
           set { _scTypes = value; }
       }

       public List<PCArealKVItem> ArealTypes
       {
           get { return _arealTypes; }
           set { _arealTypes = value; }
       }


       public int FromLayer
       {
           get { return this._setup.LayerStart; }

           set { this._setup.LayerStart = value; }
       }

       public int ToLayer
       {

           get { return this._setup.LayerEnd; }

           set { this._setup.LayerEnd = value; }


       }

       public double Elevation
       {
           get { return this._setup.DefaultElevation; }

           set { this._setup.DefaultElevation = value; }
 
       }


        #endregion



        #region 公共方法

       public void Confirm()
       {
           foreach (PCSCKVItem item in this._scTypes)
           {
               this._setup.ScTypes[item.Key] = item.Value;
               
           }


           foreach (PCArealKVItem item in this._arealTypes)
           {
               this._setup.ArealTypes[item.Key] = item.Value;
               
           }


           foreach (PCOBSKVItem  item in this._obsTypes)
           {
               this._setup.ObservationTypes[item.Key] = item.Value;

           }




       }


        #endregion


    }

    /// <summary>
    /// 用于表示一个类型设置对象
    /// </summary>

   public class PCSCKVItem
   {


       public PCSCKVItem(MAPSCType key, bool value)
       {
           this._key = key;

           this._value = value;


       }

       MAPSCType _key;

       public MAPSCType Key
       {
           get { return _key; }
           set { _key = value; }
       }

    

       bool _value;

       public bool Value
       {
           get { return _value; }
           set { _value = value; }
       }
 
   }


   public class PCArealKVItem
   {


       public PCArealKVItem(MAPArealType key, bool value)
       {
           this._key = key;

           this._value = value;


       }

       MAPArealType _key;

       public MAPArealType Key
       {
           get { return _key; }
           set { _key = value; }
       }



       bool _value;

       public bool Value
       {
           get { return _value; }
           set { _value = value; }
       }

   }


     public class PCOBSKVItem
   {


         public PCOBSKVItem(MAPObservationType key, bool value)
       {
           this._key = key;

           this._value = value;


       }

         MAPObservationType _key;

         public MAPObservationType Key
       {
           get { return _key; }
           set { _key = value; }
       }

    

       bool _value;

       public bool Value
       {
           get { return _value; }
           set { _value = value; }
       }
 
   }



}
